<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公益活动报名列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>报名用户id：</label>
                                <input type="text" name="userId"/>
                            </li>
                            <li>
                                <label>报名用户姓名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>报名用户电话：</label>
                                <input type="text" name="phone"/>
                            </li>
                            <li>
                                <label>公益活动id：</label>
                                <input type="text" name="activitiesId"/>
                            </li>
                            <li>
                                <label>申请审核图片或视频：</label>
                                <input type="text" name="url"/>
                            </li>
                            <li>
                                <label>状态0待提交1待审核2通过3驳回：</label>
                                <select name="status">
                                    <option value=""></option>
                                    <option value="0">待提交</option>
                                    <option value="1">待审核</option>
                                    <option value="2">通过</option>
                                    <option value="3">驳回</option>

                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jiajia:jiajiaCharityActivitiesEnroll:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jiajia:jiajiaCharityActivitiesEnroll:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="jiajia:jiajiaCharityActivitiesEnroll:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="jiajia:jiajiaCharityActivitiesEnroll:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('jiajia:jiajiaCharityActivitiesEnroll:edit')}]];
        var removeFlag = [[${@permission.hasPermi('jiajia:jiajiaCharityActivitiesEnroll:remove')}]];
        var prefix = ctx + "jiajia/jiajiaCharityActivitiesEnroll";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "公益活动报名",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'userId',
                    title: '报名用户id'
                },
                {
                    field: 'name',
                    title: '报名用户姓名'
                },
                {
                    field: 'phone',
                    title: '报名用户电话'
                },
                {
                    field: 'activitiesId',
                    title: '公益活动id'
                },
                {
                    field: 'url',
                    title: '申请审核图片或视频'
                },
                {
                    field: 'content',
                    title: '申请审核内容'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter:function (value, row, index) {
                        var actions = [];
                        if (row.status == 0) {
                            actions.push('<i class="fa fa-edit" style="color: #ffff00">待提交</i>');
                        } else if (row.status == 1) {
                            actions.push('<i class="fa fa-edit" style="color: goldenrod">待审核</i>');
                        } else if (row.status == 2){
                            actions.push('<i class="fa fa-edit" style="color: #11bf79">成功</i>');
                        } else {
                            actions.push('<i class="fa fa-edit" style="color: red">失败</i>');
                        }
                        return actions.join('');
                    }

                },
                {
                    field: 'rejected',
                    title: '驳回原因'
                },
                {
                    title: '审核',
                    align: 'status',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (row.status == 1) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="onTongGuoClick(\'' + row.id + '\')"><i class="fa fa-check-square-o"></i>通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="unTongGuoClick(\'' + row.id + '\')"><i class="fa fa-remove"></i>驳回</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function onTongGuoClick(id) {
            var data = {
                "id": id,
                "status": 2,
                "cause": ""
            }
            $.modal.confirm("确认通过吗?", function () {
                $.operate.submit(prefix + "/audit", "post", "json", data, function (res) {

                });
            });
        }

        function unTongGuoClick(id) {
            layer.prompt({title: '请说明未通过原因，并确认', formType: 2}, function (text, index) {
                layer.close(index);
                var data = {
                    "id": id,
                    "status": 3,
                    "rejected": text
                }
                $.operate.submit(prefix + "/audit", "post", "json", data, function (res) {

                });
            });
        }
    </script>
</body>
</html>